package org.goldenport.g3.sample

import org.goldenport.util.QSymbol
import org.goldenport.g3._
import org.goldenport.g3.adapters._
import org.goldenport.g3.messages._
import org.goldenport.g3.messages.entity._
import BookEventSpace._
import BookEntitySpace._

/**
 * @since   Aug. 31, 2010
 * @version Aug. 31, 2010
 * @author  ASAMI, Tomoharu
 **/
class BookEventDriver(val uri: String) extends G3EventDriver {
  def this() = this("XXX")

  def new_Agent(cmd: G3Command, ctx: G3AgentContext) = {
    QSymbol(cmd.uri) match {
      case EVENT_PUBLISH => new BookEventDriverAgent(uri, ctx)
    }
  }
}

class BookEventDriverAgent(uri: String, context: G3AgentContext) extends G3EntityEventDriverAgent(uri, context) {
  val entityName: QSymbol = EVENT_PUBLISH
  val schema = Schema(
    ('author, XEntityReference(KIND_PUBLISH))
  )
}

object BookEventSpace {
  val EVENT_PUBLISH = QSymbol('viewbook)
}
